<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/md5.asp"-->
<!--#include file="../common/admin.asp"-->
<%
id=request.QueryString("id")
if id<>"" then
	set rs=server.CreateObject("adodb.recordset")
	sql="select * from fare where id="&id&""
	rs.open sql,conn,1,3
	if not rs.eof then
	     fid=rs("fid")
		 sort=rs("sort")
	     title=rs("title")
		 startweight=rs("startweight")
		 endweight=rs("endweight")
		 startprice=rs("startprice")
		 endprice=rs("endprice")
	rs.close
	set rs=nothing
	end if
end if
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>add</title>
<link href="../css/style.css" rel="stylesheet" type="text/css"/>
<style>body {background-color: #eaece1;}</style>
</head>

<body>
<div class="main">
  <div class="main-title">操作</div>
  <div class="main-content">
  <%if id<>"" then%>
  <table width="100%" border="0" cellspacing="1" cellpadding="3" class="tab">
  <form action="" method="post">
  <tr>
    <td width="21%" bgcolor="#FFFFFF">标题</td>
    <td width="79%" bgcolor="#FFFFFF"><input name="title" type="text" class="input" id="title" value="<%=title%>" /></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">序号</td>
    <td bgcolor="#FFFFFF"><input name="sort" type="text" class="input" id="sort" value="<%=sort%>" /></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">物流方式</td>
    <td bgcolor="#FFFFFF"><select name="fid" id="fid">
    <%
					  set rsm=server.CreateObject("adodb.recordset")
					  sql="select * from faretype"
					  rsm.open sql,conn,1,3
					  if not rsm.eof then
					  do while not rsm.eof
					  %>
      <option value="<%=rsm("id")%>"<%if fid=rsm("id") then response.Write " selected"%>><%=rsm("title")%></option>
       <%
					  rsm.movenext
					  loop
					  rsm.close
					  set rsm=nothing
					  end if		 
					  %>
    </select></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">起始重量</td>
    <td bgcolor="#FFFFFF"><textarea name="content" id="content" style="display:none"><%=content%></textarea>
      <input name="startweight" type="text" class="input" id="startweight" value="<%=startweight%>" />
      g</td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">最大重量</td>
    <td bgcolor="#FFFFFF"><input name="endweight" type="text" class="input" id="endweight" value="<%=endweight%>" />
      g</td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">价格</td>
    <td bgcolor="#FFFFFF"><input name="startprice" type="text" class="input" id="startprice" value="<%=startprice%>" />
      日元</td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF"><input type="submit" name="button" id="button" value="保存" />
      </td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
  <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
  <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    </form>
  </table>
  <%else%>
  <table width="100%" border="0" cellspacing="1" cellpadding="3" class="tab">
  <form action="" method="post">
  <tr>
    <td width="21%" bgcolor="#FFFFFF">标题</td>
    <td width="79%" bgcolor="#FFFFFF"><input name="title" type="text" class="input" id="title" /></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">序号</td>
    <td bgcolor="#FFFFFF"><input name="sort" type="text" class="input" id="sort" /></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">物流方式</td>
    <td bgcolor="#FFFFFF"><select name="fid" id="fid">
    <%
					  set rsm=server.CreateObject("adodb.recordset")
					  sql="select * from faretype"
					  rsm.open sql,conn,1,3
					  if not rsm.eof then
					  do while not rsm.eof
					  %>
      <option value="<%=rsm("id")%>"><%=rsm("title")%></option>
       <%
					  rsm.movenext
					  loop
					  rsm.close
					  set rsm=nothing
					  end if		 
					  %>
    </select></td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">起始重量</td>
    <td bgcolor="#FFFFFF"><textarea name="content" id="content" style="display:none"></textarea>
      <input name="startweight" type="text" class="input" id="startweight" />
      g</td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">最大重量</td>
    <td bgcolor="#FFFFFF"><input name="endweight" type="text" class="input" id="endweight" />
      g</td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">价格</td>
    <td bgcolor="#FFFFFF"><input name="startprice" type="text" class="input" id="startprice" />
      日元</td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF"><input type="submit" name="button" id="button" value="添加" />
      </td>
  </tr>
  <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
  <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
  <tr>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    <td bgcolor="#FFFFFF">&nbsp;</td>
    </tr>
    </form>
  </table>
  <%end if%>
</div>
</div>
</body>
</html>
<%
if request.Form("button")="添加" then

      fid=inHTMLx(request.Form("fid"))
	  sort=inHTMLx(request.Form("sort"))
	  title=inHTMLx(request.Form("title"))
	  startweight=inHTMLx(request.Form("startweight"))
	  endweight=inHTMLx(request.Form("endweight"))
	  startprice=request.Form("startprice")
	  endprice=request.Form("endprice")

	  if fid="" or sort="" or title="" or startweight="" or endweight="" or startprice="" then
	  response.write"<script>alert('全部不能为空');</script>"
	  response.write"<script>window.history.back(-1);</script>"
	  response.end
	  end if
	  
	  set rsx=server.createobject("adodb.recordset")
	  sql="select * from fare"
	  rsx.open sql,conn,1,3
	  rsx.addnew
	  rsx("fid")=fid
	  rsx("sort")=sort
	  rsx("title")=title
	  rsx("startweight")=startweight
	  rsx("endweight")=endweight
	  rsx("startprice")=startprice
	  rsx("endprice")=0'endprice
	  rsx.update
	  response.write"<script language=JavaScript>{window.alert('添加成功！');window.location.href='view.asp';}</script>"
	  rsx.close
	  set rsx=nothing

elseif request.Form("button")="保存" then

	  fid=inHTMLx(request.Form("fid"))
	  sort=inHTMLx(request.Form("sort"))
	  title=inHTMLx(request.Form("title"))
	  startweight=inHTMLx(request.Form("startweight"))
	  endweight=inHTMLx(request.Form("endweight"))
	  startprice=request.Form("startprice")
	  endprice=request.Form("endprice")

	  if fid="" or sort="" or title="" or startweight="" or endweight="" or startprice="" then
	  response.write"<script>alert('全部不能为空');</script>"
	  response.write"<script>window.history.back(-1);</script>"
	  response.end
	  end if
	  
	  set rsx=server.createobject("adodb.recordset")
	  sql="select * from fare where id="&id&""
	  rsx.open sql,conn,1,3
	  rsx("fid")=fid
	  rsx("sort")=sort
	  rsx("title")=title
	  rsx("startweight")=startweight
	  rsx("endweight")=endweight
	  rsx("startprice")=startprice
	  rsx("endprice")=0'endprice
	  rsx.update
	  response.write"<script language=JavaScript>{window.alert('保存成功！');window.location.href='add.asp?id="&id&"';}</script>"
	  rsx.close
	  set rsx=nothing
end if
%>